package com.tuocent.dagv2.controller;

import com.tuocent.dagv2.common.AjaxResult;
import com.tuocent.dagv2.service.*;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("archives")
public class ArchivesController {
    @Autowired
    public IArchivesService archivesService;
    @Autowired
    private IArchivesFilesService archivesFilesService;
    @Autowired
    private IArchivesRecordService archivesRecordService;
    @Autowired
    private IWorkReceiveService workReceiveService;
    @Autowired
    private IArchivesInfoService archivesInfoService;


    @GetMapping("archivesInfo")
    public String archivesInfo(Model model) {
        return archivesService.archivesInfo(model);
    }

    @GetMapping("archivesHome")
    public String archivesHome(Model model) {
        return archivesService.archivesHome(model);
    }

    @GetMapping("archivesFile")
    public String archivesFile(Model model,
                               @RequestParam("pid") String pid,
                               @RequestParam("tid") String tid,
                               @RequestParam("classId") String classId) {
        return archivesService.archivesFile(model, pid, tid, classId);
    }

    @PostMapping("getArchivesFile")
    @ResponseBody
    public AjaxResult getArchivesFile(@RequestBody Map<String, Object> params) {
        return archivesFilesService.getArchivesFile(params);
    }

    @PostMapping("getArchivesRecord")
    @ResponseBody
    public AjaxResult getArchivesRecord(@RequestBody Map<String, Object> params) {
        return archivesRecordService.getArchivesRecord(params);
    }

    @PostMapping("getUserReceiveData")
    @ResponseBody
    public AjaxResult getUserReceiveData(HttpSession session,
                                         @RequestBody Map<String, Object> params) {
        return workReceiveService.getUserReceiveData(session, params);
    }

    /**** 档案追溯 *************************************************/
    @RequestMapping("archivesRetrospect")
    public String archivesRetrospect(Model model) {
        return archivesInfoService.archivesRetrospect(model);
    }

    @RequestMapping("getArchivesRetrospectData")
    @ResponseBody
    public AjaxResult getArchivesRetrospectData(@RequestBody Map<String, Object> param) {
        return archivesInfoService.getArchivesRetrospectData(param);
    }


}
